package com.example.mybatisplus.rest;


import com.example.mybatisplus.bean.BasParameter;
import com.example.mybatisplus.bean.User;
import com.example.mybatisplus.service.BasParameterService;
import com.example.mybatisplus.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author 3hyzy
 * @data 2020-04-01
 **/
@RestController
@RequestMapping("/testController")
public class TestController {

    @Autowired
    private UserService userService;

    @Autowired
    private BasParameterService basParameterService;


    @GetMapping(value = "/userList")
    public String userList() {
        List<User> list = userService.list();
        for (User be :
                list) {
            System.out.println(be.toString());

        }
        return list.toString();
    }

    @GetMapping(value = "/userAdd")
    public String userAdd() {
        List<User> list = userService.list();
        int size = list.size();
        for (User be :
                list) {
            System.out.println(be.toString());

        }
        User user = new User();
        int i = size + 1;
        user.setId(Long.valueOf(i));
        user.setName("name"+i);
        user.setAge(i);
        user.setEmail("email"+i);
        userService.save(user);
        return list.toString();
    }

    @GetMapping(value = "/basParameterList")
    public String basParameterList() {
        List<BasParameter> list = basParameterService.list();
        for (BasParameter be :
                list) {
            System.out.println(be.toString());

        }
        return list.toString();
    }
}
